$(function(){
	
//订单入库输入验证
var validate = $("#_arrival").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ArrivalOrders();//订单到货
    },
    rules: {
        Arrivaltime:"required",    
    },
    messages: {
        Arrivaltime:"",     
    }
});           


//申请全款支付美金输入验证 12-6
var validate = $("._payusding").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    errorPlacement : function(error, element) { 
        if (element.is(":radio")) 
            error.appendTo(element.parent().parent()); 
        else if (element.is(":checkbox")) 
            error.appendTo(element.parent().parent()); 
        else 
            error.appendTo(element.parent().next()); 
    },//调radio
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        AddUSDFlow();//添加流水
    },
    rules: {
        Amount:"required", 
        Remarks: "required", 
        Account:"required",
        ArrivalTime: "required", 
    },
    messages: {
        Amount:"",
        Remarks: "",
        Account:_("账户必选"),
        ArrivalTime:"",
        }
    });

   
    //申请充值输入验证 12-10
var validate = $("._balance").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    errorPlacement : function(error, element) { 
        if (element.is(":radio")) 
            error.appendTo(element.parent().parent()); 
        else if (element.is(":checkbox")) 
            error.appendTo(element.parent().parent()); 
        else 
            error.appendTo(element.parent().next()); 
    },//调radio
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ApplyFlow();//添加流水
    },
    rules: {
        RealName:"required", //为了解决由于网络问题导致客户信息无法加载完成却又已经提交了申请最后无法审核问题 2017-02-16
        Balance:"required",
        Amount:"required", 
        Remarks: "required", 
        Account:"required",
        ArrivalTime: "required", 
    },
    messages: {
        RealName:"",
        Balance:"",
        Amount:"",
        Remarks: "",
        Account:_("账户必选"),
        ArrivalTime:"",
    }
});


//申请美金充值输入验证 12-10
var validate = $("._usdbalance").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    errorPlacement : function(error, element) { 
        if (element.is(":radio")) 
            error.appendTo(element.parent().parent()); 
        else if (element.is(":checkbox")) 
            error.appendTo(element.parent().parent()); 
        else 
            error.appendTo(element.parent().next()); 
    },//调radio
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ApplyUSDFlow();//添加流水
    },
    rules: {
        RealName:"required", //为了解决由于网络问题导致客户信息无法加载完成却又已经提交了申请最后无法审核问题 2017-02-16
        Balance:"required",
        Amount:"required", 
        Remarks: "required", 
        Account:"required", 
        ArrivalTime: "required", 
    },
    messages: {
        RealName:"",
        Balance:"",
        Amount:"",
        Remarks: "",
        Account:_("账户必选"),
        ArrivalTime:"",
    }
});

//订单充值输入验证 class=_re
var validate = $("._re").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        AddCharge();//客户充值
    },
    rules: {
        AmountOfMoney:"required", 
        Remarks: "required", 
        PaymentModel:"required", 
        AdddateTime: "required", 
    },
    messages: {
        AmountOfMoney:"",
        Remarks: "",
        PaymentModel:"",
        AdddateTime:"",
    }
});

//订单转移输入验证 id=_transfer
var validate = $("#_transfer").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ModifyPurchaseUserID();//订单转移
    },
    rules: {
        PurchasesUserID:"required", 
    },
    messages: {
        PurchasesUserID:"",
    }
});

//作废订单输入验证 id=_invalid
var validate = $("#_invalid").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        CancelOrders();//订单作废
    },
    rules: {
        SalesRemarks:"required", 
    },
    messages: {
        SalesRemarks:"",
    }
});           

//修改运费输入验证          
var validate = $("#_frei").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ModFreight();//修改运费
    },
    rules: {
        Freight: { 
            required: true
        },                    
    },
    messages: {                    
        Freight: {
            'required': ''
        }
    }
});

//自留订单输入验证 id=_stock
var validate = $("#_stock").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        StockOrders();//订单自留
    },
    rules: {
        SalesRemarks:"required", 
    },
    messages: {
        SalesRemarks:"",
    }
});

//退回订单输入验证 id=_return
var validate = $("#_return").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ReturnOrders();//订单退回
    },
    rules: {
        SalesRemarks:"required", 
    },
    messages: {
        SalesRemarks:""
    }
});

//兑率订单输入验证 id=_exchange
var validate = $("#_exchange").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ExchangeOrders();//订单兑率
    },
    rules: {
        PurchaseExchangerate:"required", 
    },
    messages: {
        PurchaseExchangerate:_("必填"),
    }
});

//收款输入验证 id=_pay
var validate = $("#_pay").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form
    	if($("#_chargingAmount").val()>0 && $("#_optionBank").val()==""){
    		$("#_optionBank").addClass("border-red");

    	}else{
    		$("#_optionBank").removeClass("border-red");
    		PayOrders();//收款
    	}
        
    },
    rules: {
        Currency:"required", 
        ArrivalTime:"required",
        // Account:"required",
        Remarks:"required",
    },
    messages: {
        Currency:"",
        ArrivalTime:"",
        // Account:"",
        Remarks:"",
    }
});

//收款输入验证 id=_payback
var validate = $("#_payback").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        PayBackOrders();//收款
    },
    rules: {
        BankID:"required", 
        PayBackAmount:"required", 
        ArrivalTime:"required",
    },
    messages: {
        BankID:"", 
        PayBackAmount:"",
        ArrivalTime:"",
    }
});

//付款输入验证 id=_receipt
var validate = $("#_receipt").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ReceiptOrders();//付款
    },
    rules: {
        BankID:"required", 
        ArrivalTime:"required",
    },
    messages: {
        BankID:"",
        ArrivalTime:"",
    }
});

//出货订单输入验证 id=_ship
var validate = $("#_ship").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        EditShip();//订单作废
    },
    rules: {
        ShipRemarks: "required", 
    },
    messages: {
        ShipRemarks: "",
    }
});


//采购订单输入验证 class=purchase_form
var validate = $(".purchase_form").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        PurchaseOrder();//采购订单
    },
    rules: {
        Weight: "required", 
        Shape: "required", 
        Color:"required", 
        Clarity:"required", 
        Cut: "required", 
        DeliveryTime:"required", 
        SupplierCode:"required", 
        CertNo:"required", 
        PriceUSD: "required", 
        DiscountReturn: "required",                    
        PurchaseExchange: "required",
        PurchaseRemarks: "required",                    
    },
    messages: {
        Weight:"",
        Shape:"",
        Color: "",
        Clarity:"",
        Cut:"",
        DeliveryTime:"",
        SupplierCode: "",
        CertNo:"",
        PriceUSD:"",
        DiscountReturn: "",
        PurchaseExchange: "",
        PurchaseRemarks: "",
    }
});


//回裸钻库输入验证 class=_backdia
var validate = $("._backdia").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        BackDia();//添加裸钻(回裸钻库)
    },
    rules: {                    
        OriginSN: "required",
        Weight: "required", 
        Shape: "required", 
        Color:"required", 
        Clarity:"required", 
        Cut: "required", 
        SupplierCode:"required", 
        CertNo:"required", 
        Milky: "required", 
        Hue: "required",
        Status: "required", 
        Place: "required",
        PriceUSD: "required",
//		PurchaseRMB: "required",
    },
    messages: {
        OriginSN:"",                
        Weight:"",
        Shape:"",
        Color: "",
        Clarity:"",
        Cut:"",
        SupplierCode: "",
        CertNo:"",
        Milky:"",
        Hue:"",
        Status:"",
        Place:"",
        PriceUSD: "",
//		PurchaseRMB: "",
    }
});

//批量改价输入验证 id= _revise           
var validate = $("#_revise").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ReviseOrders();//批量改价
    },
    rules: {
        SalesExchangerate: "required", 
        DiscountReturn: "required", 
        Discount: "required", 
    },
    messages: {
        SalesExchangerate:_("必填"),
        DiscountReturn:_("必填"),
        Discount: _("必填"),
    }
});

//单个改价输入验证 id= _reviseOrder           
var validate = $("#_reviseOrder").validate({
    debug: true, //调试模式取消submit的默认提交功能   
    focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
    onkeyup: false,
    submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
        ReviseAnOrder();//单个改价
    },
    rules: {
        SalesExchangerate:  "required", 
        Confirmdiscount: "required", 
        ConfirmPrice:  "required", 
    },
    messages: {
        SalesExchangerate: _("必填"),
        Confirmdiscount: _("必填"),
        ConfirmPrice:  _("必填"),
    },

});

//修改所在地输入验证
	var validate = $("#_modPlace").validate({
		debug: true, //调试模式取消submit的默认提交功能   
		focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
		onkeyup: false,
		submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form   
			ModifyPlace(); //修改所在地
		},
		rules: {
			Place: "required",
		},
		messages: {
			Place: "",
		}
	});

    //修改所在地输入验证
    var validate = $("#_modStatus").validate({
        debug: true, //调试模式取消submit的默认提交功能
        focusInvalid: false, //当为false时，验证无效时，没有焦点响应
        onkeyup: false,
        submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form
            ModifyStatus(); //修改货品状态
        },
        rules: {
            Status: "required",
        },
        messages: {
            Status: "",
        }
    });

	//修改原供应商输入验证
	var validate = $("#_modPurchaseSupplier").validate({
		debug: true, //调试模式取消submit的默认提交功能   
		focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
		onkeyup: false,
		submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form   
			ModifyPurchaseSupplier(); //修改所在地
		},
		rules: {
			PurchaseSupplier: "required",
		},
		messages: {
			PurchaseSupplier: "",
		}
	});
	 //修改买价输入验证
	var validate = $("#_modPurchasePrice").validate({
		debug: true, //调试模式取消submit的默认提交功能   
		focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
		onkeyup: false,
		submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form   
			ModifyPurchasePrice(1); //修改所在地
		},
		rules: {
			purchasePrice: "required",
		},
		messages: {
			purchasePrice: "",
		}
	});	
	//修改采购汇率
	var validate = $("#_modPurchaseExchangerate").validate({
		debug: true, //调试模式取消submit的默认提交功能   
		focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
		onkeyup: false,
		submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form   
			ModifyPurchaseExchangerate(); //修改采购汇率
		},
		rules: {
			PurchaseExchangerate: "required",
		},
		messages: {
			PurchaseExchangerate: "",
		}
	});

    //修改销售汇率
    var validate = $("#_SalesExchangerate_form").validate({
        debug: true, //调试模式取消submit的默认提交功能
        focusInvalid: false, //当为false时，验证无效时，没有焦点响应
        onkeyup: false,
        submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form
            ModifySalesExchangerate(); //修改销售汇率
        },
        rules: {
            SalesExchangerate: "required",
        },
        messages: {
            SalesExchangerate: "",
        }
    });

});
